package com.fling.tutorial;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.fling.Locator;
import com.fling.observer.Subject;

public class StartState extends TutorialState {

	public StartState(TutorialManager t, Subject subject) {
		super(t, subject);
	}

	@Override
	public void update(float delta) {
		if (transition) {
			transitionTimer += delta;
			if (transitionTimer > TRANSITION_TIME) {
				exit();
			}
		}
	}

	@Override
	public void registerInput(INPUT input) {
		switch (input) {
		case FALL:
			transition = true;
			break;
		default:
			break;
		}
	}

	@Override
	public void enter() {
		if (!Locator.isTutorialCompleted()) {
			Locator.setOverallGameSpeed(0);
		}
	}

	@Override
	public void exit() {
		tutorial.changeState(new TapState(tutorial, subject));
	}

	@Override
	public void render(SpriteBatch sb, NinePatch patch, BitmapFont font) {
		patch.draw(sb, Gdx.graphics.getWidth() * 0.225f, Gdx.graphics.getHeight() * 0.6f, Gdx.graphics.getWidth() * 0.55f,
				Gdx.graphics.getHeight() * 0.15f);
		font.drawWrapped(sb, "Welcome to Fling Hero!   Tap to begin", Gdx.graphics.getWidth() * 0.25f, Gdx.graphics.getHeight() * 0.71f,
				Gdx.graphics.getHeight() * 0.32f);
	}

}
